<template>
  <el-date-picker
    size="small"
    v-model="data"
    :type="pickerType"
    align="right"
    :value-format="valueFormat"
    :placeholder="placeholder"
    @change="handleChange"
    :clearable="$attrs.clearable === false ? false : true"
    :editable="$attrs.editable === false ? false : true"
  />
</template>

<script>
export default {
  props: {
    value: {
      type: [String]
    },
    pickerType: {
      type: String,
      default: "date"
    },
    valueFormat: {
      type: String,
      default: "yyyy-MM-dd"
    },
    placeholder: {
      type: String,
      default: "请选择"
    }
  },
  data() {
    return {
      data: this.value
    }
  },
  watch: {
    value(val) {
      this.data = val
    }
  },
  methods: {
    handleChange(val) {
      // if (!val) {
      //   return this.$emit('input', ['', ''])
      // }
      this.$emit("input", val)
    }
  }
}
</script>
<style lang="less"></style>
